package com.farent.solutions.plugins.aribaweb.editor.awl;

import com.farent.solutions.plugins.aribaweb.NBawConstants;
import java.awt.EventQueue;
import java.awt.Image;
import org.netbeans.core.spi.multiview.MultiViewDescription;
import org.netbeans.core.spi.multiview.MultiViewElement;
import org.openide.util.HelpCtx;
import org.openide.util.ImageUtilities;
import org.openide.windows.TopComponent;

/**
 *
 * @author farouka
 */
public class AWLTextView  implements MultiViewDescription {

    private AWLSourceEditor editor;
    
    private AWLEditorSupport support;

    public AWLTextView(AWLEditorSupport aThis) {
        this.support = aThis;
    }

    @Override
    public int getPersistenceType() {
        return TopComponent.PERSISTENCE_ONLY_OPENED;
    }

    @Override
    public String getDisplayName() {
        return "Source";
    }

    @Override
    public Image getIcon() {
        return ImageUtilities.loadImage(NBawConstants.PROJECT_AW_FILE_ICON_PATH);
    }

    @Override
    public HelpCtx getHelpCtx() {
        return HelpCtx.DEFAULT_HELP;
    }

    @Override
    public String preferredID() {
        return "AWLCodeMultiviewDescription";
    }

    @Override
    public MultiViewElement createElement() {
        assert EventQueue.isDispatchThread();
        if (editor == null) {
            editor = new AWLSourceEditor(support);
        }
        return editor;
    }

}
